angular.module("myApp")
	.controller("SortController", ["$scope", "SortService", function($scope, SortService) {
		//将全局变量的值赋给controller的内部变量
		$scope.max = max;
		$scope.min = min;
		//获取分类主页面数据
		SortService.getData().success(function(res) {
			$scope.items = res;
			$scope.focus = 0;//默认是0 使第一个有样式
			//点击分类列表左列商品标题
			$scope.changeClassifyItem = function(i) {
				$scope.data9 = [];
				$scope.data9.push(this.item);
				$scope.focus = i;
			}
			$scope.jumpGoods = function(e){
				min = e;
				$scope.dataItem = [];
				$scope.dataItem.push(this.item);
				//console.log(this.item)
				max = this.item.parentName;
			}
		});
		//获取分类页面里面详细分类
		SortService.getData2().success(function(res) {
			$scope.goodsItem = res;
			//设置导航条滚动事件
			var myScroll;
			//判断如果this.scroller存在就调用此方法,此处也是控制台存在bug之后解决的
			if (this.scroller) {
				myScroll = new IScroll('#wrapper', {
					eventPassthrough: true,
					scrollX: true,
					scrollY: false,
					preventDefault: false
				});
			}
			$scope.focus2 = min;//样式显示到指定选择的那个列表标题 
			//点击分类下各品牌的分类标题
			$scope.changeGoodsList = function(i) {
				$scope.dataGoods = [];
				$scope.dataGoods.push(this.item);
				$scope.focus2 = i;
				console.log($scope.dataGoods)
			}
		});
	}])
	
	